﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using SayDemo.Models;

namespace SayDemo.Data
{
    public class SayDemoDbInitilizer:DropCreateDatabaseAlways<SayDemoDb>
    {
        protected override void Seed(SayDemoDb db)
        {
            db.Users.Add(new Models.Users
            {
                Username = "admin",
                Password = "123",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
            }) ;
            db.Users.Add(new Models.Users
            {
                Username = "阮",
                Password = "123",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
            });
            db.Users.Add(new Models.Users
            {
                Username = "熊",
                Password = "123",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
                Version = 0
            });
          

            db.Messages.AddRange(new List<Messages>
            {
                new Messages
                {
                    FormUserId=1,
                    Content="520你开心吗",
                    CreatedAt=DateTime.Now,
                    UpdatedAt=DateTime.Now,
                    Version=0
                },
                 new Messages
                {
                    FormUserId=2,
                    Content="520你幸福吗",
                    CreatedAt=DateTime.Now,
                    UpdatedAt=DateTime.Now,
                    Version=0
                },
                  new Messages
                {
                    FormUserId=3,
                    Content="520你快乐吗",
                    CreatedAt=DateTime.Now,
                    UpdatedAt=DateTime.Now,
                    Version=0
                },
            }
                );

            db.Comments.AddRange(new List<Comments>
            {
                new Comments
                {
                    FromUserId=1,
                    MsgId=1,
                    Content="666666",
                    CreatedAt=DateTime.Now,
                    UpdatedAt=DateTime.Now,
                    Version=0

                },
                 new Comments
                {
                    FromUserId=2,
                    MsgId=2,
                    Content="halo",
                    CreatedAt=DateTime.Now,
                    UpdatedAt=DateTime.Now,
                    Version=0

                },
                  new Comments
                {
                    FromUserId=1,
                    MsgId=3,
                    Content="你好",
                    CreatedAt=DateTime.Now,
                    UpdatedAt=DateTime.Now,
                    Version=0

                },
             
            });

            db.SaveChanges();

            base.Seed(db);
        }
    }
}